package com.situ.day7;

//Java是单继承
public class Student extends Person{
    //private int id;
    //private String name;
    //private int age;
    //特有属性
    private String className;

    public Student() {
        //new Person();
        super();
    }

    public Student(String className) {
        // new Person()
        //super();
        this.className = className;
    }

    //在Java里面new子类对象的时候首先new出父类对象
    public Student(int id, String name, int age, String className) {
        // new Person(int id, String name, int age)
        super(id, name, age);
        //继承父类的属性，子类就可以当成自己的属性使用
        //this.id = id;
        //this.name = name;
        //this.age = age;
        this.className = className;
    }

    //    public void show() {
//        System.out.println("Student.show");
//    }

    //特有方法
    public void study() {
        System.out.println(name + "正在学习");
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    //重载和重写（覆盖）
    @Override
    public void show() {
        System.out.println("Student.show");
    }

    // Ctrl+Shift+/
    //重写（也叫覆盖）:继承父类的方法子类不满意，子类按照自己的需求重新定义这个方法
    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", className='" + className + '\'' +
                '}';
    }
}
